package com.spring.learn.controller;

import com.spring.learn.domain.TbUser;
import com.spring.learn.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;
    @Value("${test.name}")
    private String name;

    @GetMapping("/{id}")
    public TbUser queryByPrimaryKey(@PathVariable Long id) {
        System.out.println("配置文件中的test.name = " + name);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return userService.queryByPrimaryKey(id);
    }
}
